const Actions = require('./actions');
const DB = require('app/db');
const Storage = require('clientConfig/util/StoreData').Storage;

module.exports = Reflux.createStore({
    listenables: [Actions],
    data: {
    },

    onFetch: function(params, cb) {
        let t = this;
        console.log(params)
        DB.Table.get_table_data({ 
            id: Storage.get('user.id'),
            annual: params ? params : ""
        }).then((content)=>{
            var table_data = {};
            table_data.data = content.list;
            table_data.totalCount = content.total_count;
            t.data.table_data = table_data;      
            t.updateComponent();
        })
    },

    updateComponent: function() {
        this.trigger(this.data);
    },

    getInitialState: function() {
        return this.data;
    }
});
